var head =' ';
var list = [];
var uid = 0;
getUserName()
function getUserName(){
    $.ajax({
		url:ajax_host+'getUserName.act',
    	dataType:'JSON',
    	success:function(resp){
    		if(resp.success){
                console.log(resp.user)
                uid = resp.user.uId
                list = resp.user
                html('userName',resp.user.uName)
                html('score',resp.user.uMoney)
                head=resp.user.head;
                if(head != " "){
                 var adres="/image/"+head;
                document.getElementById('imgInit').src = adres;
                }else{
                   head = "public/img/nohead.png";
                   document.getElementById('imgInit').src = head;
                }
                
    		}else{
                layer.alert('获取用户名失败')
            }
    	},
    	error:function(resp){
    		layer.alert('获取用户名失败')
    	}
	});
}


function myinfo(){
    console.log('获取遮罩');

    if(head != " "){
        var adres="/image/"+head;
       document.getElementById('imgInitt').src = adres;
       }else{
          head = "public/img/nohead.png";
          document.getElementById('imgInitt').src = head;
       }

    $('#myinfo').modal({
        show:true,//展示出来
        moveable:true,//可移动
        rememberPos:true,//记住移动位置
        backdrop:'static'//背景遮罩
    });
    html('name',list.uName);
    if(list.uSex==1){
        html('sex','男');
    }else{
        html('sex','女');
    }
    
    html('tel',list.tell);
    
}



function doUpdatee(){
    console.log('获取修改遮罩');
    $('#doUpdatee').modal({
        show:true,//展示出来
        moveable:true,//可移动
        rememberPos:true,//记住移动位置
        backdrop:'static'//背景遮罩
    });

}

function confirm(){
    // $('#doUpdate').modal('hide', 'fit');
    var uName = val('uName');
    var uTell = val('uTell');
    var uPwd = val('uPwd');
    var cPwd = val('cPwd');
    console.log(uName+" "+uTell+" "+uPwd+" "+cPwd+" "+uid);
    $.ajax({
		url:ajax_host+'userEdit.act',
		type : 'post',
		dataType:'JSON',
		data:{
            uid:uid,
            uName:uName,
            uTell:uTell,
            uPwd:uPwd,
            cPwd:cPwd,
            head:head
		},
		success:function(resp){
			
			if(resp.success){
				//关闭遮罩
				$('#doUpdate').modal('hide', 'fit');
				layer.alert('修改成功');
			}else{
				$('#doUpdate').modal('hide', 'fit');
				layer.alert(resp.errmsg);
			}
		}
})
}

function myMoney(){
    console.log('打开充值界面');
    $('#myMoney').modal({
        show:true,//展示出来
        moveable:true,//可移动
        rememberPos:true,//记住移动位置
        backdrop:'static'//背景遮罩
    });
}
function confirm2(){
    // $('#myMoney').modal('hide', 'fit');
    var money = val('money');
    console.log(money+"   "+uid);
    $.ajax({
		url:ajax_host+'useraddMoney.act',
		type : 'post',
		dataType:'JSON',
		data:{
            uid:uid,
            money:money
		},
		success:function(resp){
			
			if(resp.success){
				//关闭遮罩
				$('#myMoney').modal('hide', 'fit');
                layer.alert('充值成功');
                html('score',resp.newMoney);
			}else{
				$('#myMoney').modal('hide', 'fit');
				layer.alert(resp.errmsg);
			}
		}
})
}

function mylogistics(){
    $('#frame').attr("src","page.act?p="+"mylogistics"+"&h="+Math.random());
}

function orders(){
    $('#frame').attr("src","page.act?p="+"orders"+"&h="+Math.random());
}
function network(){
    $('#frame').attr("src","page.act?p="+"network"+"&h="+Math.random());
}

function contraband(){
    $('#frame').attr("src","page.act?p="+"contraband"+"&h="+Math.random());
}
function gethead(){
    $('#uploaderExample').uploader({
        autoUpload: true,            //当选择文件后立即自动进行上传操作
        chunk_size:0,
        url: 'upload.act' , //文件上传提交地址
       
       filters:{
       //获得数据库有关类型进行动态过滤
       mime_types: [
        {title: '图片', extensions: 'jpg,gif,png'},
        {title: '图标', extensions: 'ico'}
       ],
       prevent_duplicates: true
       },
       responseHandler:function(responseObject, file){
           //服务器的响应
           layer.alert('上传成功');
           console.log(responseObject, file);
          
       }
       });
}